home *** CD-ROM | disk | FTP | other *** search
- #include "lib.h"
-
- /* getlogin(3)
- *
- * Author: Terrence W. Holm Aug. 1988
- */
-
- #include <stdio.h>
- #include <pwd.h>
-
- #ifndef L_cuserid
- #define L_cuserid 9
- #endif
-
- #ifdef __STDC__
- extern struct passwd *getpwuid(int);
- #else
- extern struct passwd *getpwuid();
- #endif
-
- char *getlogin()
- {
- static char userid[ L_cuserid ];
- struct passwd *pw_entry;
-
- pw_entry = getpwuid( getuid() );
-
- if ( pw_entry == NULL )
- return( (char *)NULL );
-
- strcpy( userid, pw_entry->pw_name );
-
- return( userid );
- }
-